package org.example.controller;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.concurrent.TimeUnit;

@RestController
public class SentinelController {
    @RequestMapping(value = "sentinel1")
    public String sentinel1() throws InterruptedException {
        TimeUnit.SECONDS.sleep(1); //沉睡一秒
        return "sentinel1";
    }

    @RequestMapping(value = "sentinel2")
    public String sentinel2(){
        return "sentinel2";
    }

    @RequestMapping(value = "sentinel3")
    public String sentinel3(){
        return "sentinel3";
    }

    int i = 0;
    @RequestMapping("/fallBack")
    public String fallBack(){
        if (++i%3==0){
            throw new RuntimeException();
        }
        return "fallBack";
    }

}
